﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace XMM.Dialoges
{
    /// <summary>
    /// Interaktionslogik für AddAudience.xaml
    /// </summary>
    public partial class AddAudience : Window
    {
        ManageAudiences ParentAudienceManager;

        public AddAudience(ManageAudiences dlgParentAudienceManager)
        {
            InitializeComponent();

            ParentAudienceManager = dlgParentAudienceManager;
        }

        private void btnAbort_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text != String.Empty)
            {
                if (MessageBox.Show("Möchten Sie Ihre Eingabe wirklich verwerfen?", "Wirklich Abbrechen?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                    return;
            }

            Close();
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text != String.Empty)
            {
                Objects.Audition oNewAudition = new Objects.Audition();
                oNewAudition.Name = txtName.Text;
                oNewAudition.LogHistory = (bool)chkLogHistory.IsChecked;
                if (oNewAudition.SaveNew())
                {
                    ParentAudienceManager.loadAudiences();
                    Close();
                }
                //Objects.Audition oNewAudition = new Objects.Audition(txtName.Text, chkLogHistory.IsChecked);
            }
            else
            {
                MessageBox.Show("Bitte geben Sie zuerst eine Bezeichnung ein!", "Keine Zuseherbezeichnung", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
    }
}
